package com.vpclub.vpclubdemo.webapi;

import com.vpclub.vpclubdemo.Services.CategoryService;
import com.vpclub.vpclubdemo.model.Category;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;
@Controller
public class HelloController {
    @Autowired
    private CategoryService categoryServiceImp;
    @RequestMapping("/index")
    public String index(Map<String,Object> map)
    {
        map.put("name","world");
        return "login/login";
    }

    @RequestMapping(value = "/category/add", method = RequestMethod.POST)
    @ResponseBody
    public Category addcate()
    {
        Category newCate=new Category();
        newCate.setCategoryname("newCategory");
        newCate.setCreatetime(new Date());
        newCate.setCreatorid(1000);
        newCate.setIsdeleted(false);
        newCate.setParentid(0);
        newCate.setIsdeleted(false);
        newCate.setSortid(99);

        categoryServiceImp.insert(newCate);
        return  newCate;

    }
}
